﻿using System;
using awsomeSyntezator.PipeLine.Envelopes;

namespace awsomeSyntezator.PipeLine.Oscilators.Effects
{
	class RocketEngine : Oscilator
	{
		private RedNoise src;
		private RedNoise densityGenerator;
		private Tremolo envelope;

		private float scale;

		public RocketEngine(int strenght) : base(0, 0, strenght)
		{
			src = new RedNoise(Options.noiseDensity, 1);
			densityGenerator = new RedNoise(Options.noiseDensity, 1);
			envelope = new Tremolo(Options.effectResonance, Options.noiseEffectCutOffFrequency);
			type = 0;

			scale = Options.noiseDensity;
		}

		public override double getSample(int n, double sample)
		{
			src.density = (int) (((densityGenerator.getSample(n, sample) + 1.0)/ 2.0) * scale);
			return envelope.getSample(n, src.getSample(n, sample));

		}
	}
}
